package org.quartz.No01简单的定时任务;

import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

import java.text.ParseException;
import java.util.Date;

public class SimpleScheduler {
    public static void main(String args[]) throws SchedulerException, ParseException {
        JobDetail jobDetail= JobBuilder.newJob(SimpleDemoJob.class)
                .withIdentity("testJob_1","group_1")
                .build();

        Trigger trigger= TriggerBuilder
                .newTrigger()
                .withIdentity("trigger_1","group_1")
                .startNow()
                .withSchedule(SimpleScheduleBuilder.simpleSchedule()
                        .withIntervalInSeconds(10) //时间间隔
                        .withRepeatCount(5) //重复次数(将执行6次)
                )
                .build();
        SchedulerFactory sf = new StdSchedulerFactory();
        Scheduler sched = sf.getScheduler();

        sched.scheduleJob(jobDetail,trigger);

        sched.start();

    }
}